//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class Otherwise: IOfficeXmlSerializable
    {
        internal const string xmlName = "else";
        private string _name;
        readonly List<IOfficeXmlSerializable> _items=  new List<IOfficeXmlSerializable>();

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                _name = c.GetOptionalString("name", string.Empty);
                _items.Clear();
                _items.AddRange(ReaderHelper.ReadItems(c));
            }

        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.SetOptionalString("name", _name, string.Empty);
                c.WriteElements(_items);
            }
        }
    }
}